<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Wap\Controller;
use Think\Controller;

/**
 * 前台公共控制器
 * 为防止多分组Controller名称冲突，公共Controller名称统一使用分组名称
 */
class HomeController extends Controller {
    
    protected function _initialize(){
        define ( "UID", is_login () );
    }



    /**
     * 获取用户注册错误信息
     * @param  integer $code 错误编码
     * @return string        错误信息
     */
    public function showRegError($code = 0){
        switch ($code) {
            case -1:  $error = '用户名长度必须在16个字符以内！'; break;
            case -3:  $error = '用户名被占用！'; break;
            case -4:  $error = '密码长度必须在6-30个字符之间！'; break;
            case -9:  $error = '手机格式不正确！'; break;
            case -11: $error = '手机号被占用！'; break;
            default:  $error = '未知错误';
        }
        return $error;
    }

    /**
     *导出excel
     */
    public function exportExcel(){
        $uid=is_login();
        $map['introducer_id']=$uid;
        $map['type']=2;
        $list=M('student_info')
            ->alias('a')
            ->join('vo_major as b ON a.major=b.id')
            ->field('a.id,a.name,a.ID_number,a.home_address,a.school,b.title,a.introducer,a.introducer_phone,a.pay_evidence,a.create_time,a.update_time,a.manage_update_time')
            ->where($map)
            ->select();
        foreach ($list as $k=>&$vo){
            $vo['create_time']=time_format($vo['create_time']);
            $vo['update_time']=time_format($vo['update_time']);
            $vo['manage_update_time']=time_format($vo['manage_update_time']);
            $vo['pay_evidence']=empty($vo['pay_evidence'])?"未缴费":'已缴费';
        }
        exportexcel($list,array('编号','姓名','身份证号','家庭住址','毕业院校','专业','介绍人','介绍人电话','是否缴费','首次提交时间','最后一次修改时间','管理员修改时间'),'info');
    }

}
